/**
 * describe:
 *
 * @author chaP
 * @date 2019/03/21
 */
package CodingTest.AC20190321;

public class flatten {
    class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(int val) {
            this.val = val;
        }
    }
    public void flatten(TreeNode root){
        if(root == null) return ;
        flatten(root.left);
        flatten(root.right);
        if(root.left != null){
            TreeNode node = root.left;
            while(node.right != null){
                node = node.right;
            }
            node.right = root.right;
            root.right = root.left;
            root.left = null;
        }


    }
}
